<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
// import { Toast } from "vant";
export default {
  name: 'App',
  components: {
  },
  data(){
    return{
      timer:null
    }
  },
  methods: {
    goback() {
      this.$router.back();
    }
  },
  created() {
    // 移动端返回键监听
    window.history.pushState(null, null, "#");
    this.onPlusReady(() => {
      window.plus.key.addEventListener(
        "backbutton",
        () => {
          this.goback();
          /* let hashArr = ['#/index','#/games','#/mining','#/wallet','#/mine'];
          if (hashArr.indexOf(location.hash)!==-1) {
            if(!this.timer){
              // 如果定时器为空，表示短时间内第一次点击返回
              Toast({
                message:this.$t('exit.exit'),
                position:"bottom"
              });
              this.timer = setTimeout(()=>{
                clearTimeout(this.timer);
                this.timer = null;
              },2000)
            }else{
              // 短时间内第二次点击返回，直接退出
              clearTimeout(this.timer);
              this.timer = null;
              window.plus.runtime.quit();
            }
          } else {
            if(location.hash.indexOf("/importKey?type=getKey")!==-1){
              this.$router.push("/wallet")
            }else{
              if(location.hash.indexOf('/gameContent')!==-1){
                window.plus.webview.close(window.embed);
              }
              this.goback();
            }
          } */
        },
        false
      );
    });
  }
}
</script>

<style>
</style>
